<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>touch与click</title>
    <style>
        * {
            margin: 0;
            padding: 0;

        }

        #demo {
            width: 100%;
            height: 300px;
            background-color: skyblue;
        }
    </style>
</head>

<body>
    <div id="demo"></div>

    <script>
        const demo = document.getElementById('demo');

        let time;

        demo.addEventListener('click', () => {
            console.log('click事件触发了', Date.now() - time + 'ms');
        })

        // 移动端touchstart事件就是比click事件优先级高
        demo.addEventListener('touchstart', () => {
            time = Date.now();
            console.log('touchstart事件触发了');
        })

    </script>
</body>

</html>